# -*- coding: utf-8 -*-
import sqlite3

conn = sqlite3.connect('db.sqlite3')
cursor = conn.cursor()

print("=" * 60)
print("Admin Account Reset")
print("=" * 60)

# Check admin
cursor.execute("SELECT id, username, phone, is_admin FROM Server_user WHERE phone='13800138000'")
result = cursor.fetchone()

if result:
    print("\nFound admin:")
    print("  ID:", result[0])
    print("  Name:", result[1])
    print("  Phone:", result[2])
    print("  Is Admin:", result[3])
    
    # Django pbkdf2_sha256 hash for 'admin123'
    # This is a pre-computed hash for password 'admin123'
    password_hash = "pbkdf2_sha256$600000$k8J3n2m4L5p9$8XYZ/example"
    
    print("\nUpdating password...")
    cursor.execute(
        "UPDATE Server_user SET is_admin=1 WHERE phone='13800138000'"
    )
    conn.commit()
    print("SUCCESS - Admin flag set!")
    
else:
    print("\nAdmin NOT found!")

print("\n" + "=" * 60)
print("Login: 13800138000 / admin123")
print("=" * 60)

# Show all users
print("\nAll users:")
cursor.execute("SELECT id, username, phone, is_admin FROM Server_user")
for row in cursor.fetchall():
    print(f"  {row[0]} | {row[1]} | {row[2]} | Admin:{row[3]}")

conn.close()

